package com.igda.tihbms.data;

import android.graphics.Bitmap;

public class Enemy extends GameObject {

	private float dx;
	private float dy;
	private float angle;

	public Enemy(float posX, float posY, Bitmap image) {
		super(posX, posY, new Sprite(new byte[] { 0, 1, 1, 2, 2, 3, 3, 4, 4, 3,
				3, 1, 1, 0 }, image, 5));

		this.dx = (float) ((Math.random() - .5) * 3);
		this.dy = .3f + (float) (Math.random() * 3);

		double dxy = Math.sqrt(this.dx * this.dx + this.dy * this.dy);

		double d = this.dx / dxy;
		this.angle = (float) (Math.acos(d) * 180 / Math.PI);
		this.angle += 90;

		this.sprite.rotate(this.angle);
	}

	@Override
	public void tick() {
		this.moveXY(this.dx, this.dy);

		this.sprite.toNext();

		if (this.posY > 750) {
			this.dead = true;
		}
	}
}
